unit klavye2;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ExtCtrls, Buttons,fcButton, fcImgBtn, fcShapeBtn,
  fcClearPanel, fcButtonGroup;

type
  TKlavye2f = class(TForm)
    Timer1: TTimer;
    BitBtn1: TBitBtn;
    fcButtonGroup1: TfcButtonGroup;
    fcButtonGroup1fcShapeBtn1: TfcShapeBtn;
    fcButtonGroup1fcShapeBtn2: TfcShapeBtn;
    fcButtonGroup1fcShapeBtn3: TfcShapeBtn;
    fcButtonGroup1fcShapeBtn4: TfcShapeBtn;
    fcButtonGroup1fcShapeBtn5: TfcShapeBtn;
    fcButtonGroup1fcShapeBtn6: TfcShapeBtn;
    fcButtonGroup1fcShapeBtn7: TfcShapeBtn;
    fcButtonGroup1fcShapeBtn8: TfcShapeBtn;
    fcButtonGroup1fcShapeBtn9: TfcShapeBtn;
    fcButtonGroup1fcShapeBtn10: TfcShapeBtn;
    fcButtonGroup1fcShapeBtn11: TfcShapeBtn;
    fcButtonGroup1fcShapeBtn12: TfcShapeBtn;
    fcButtonGroup2: TfcButtonGroup;
    fcButtonGroup2fcShapeBtn1: TfcShapeBtn;
    Memo1: TMemo;
    fcButtonGroup3: TfcButtonGroup;
    fcShapeBtn1: TfcShapeBtn;
    fcShapeBtn2: TfcShapeBtn;
    fcShapeBtn3: TfcShapeBtn;
    fcShapeBtn4: TfcShapeBtn;
    fcShapeBtn5: TfcShapeBtn;
    fcShapeBtn6: TfcShapeBtn;
    fcShapeBtn7: TfcShapeBtn;
    fcShapeBtn8: TfcShapeBtn;
    fcShapeBtn9: TfcShapeBtn;
    fcShapeBtn10: TfcShapeBtn;
    fcShapeBtn11: TfcShapeBtn;
    fcButtonGroup4: TfcButtonGroup;
    fcShapeBtn12: TfcShapeBtn;
    fcShapeBtn13: TfcShapeBtn;
    fcShapeBtn14: TfcShapeBtn;
    fcShapeBtn15: TfcShapeBtn;
    fcShapeBtn16: TfcShapeBtn;
    fcShapeBtn17: TfcShapeBtn;
    fcShapeBtn18: TfcShapeBtn;
    fcShapeBtn19: TfcShapeBtn;
    fcShapeBtn20: TfcShapeBtn;
    fcButtonGroup5: TfcButtonGroup;
    fcShapeBtn21: TfcShapeBtn;
    fcButtonGroup6: TfcButtonGroup;
    fcShapeBtn22: TfcShapeBtn;
    fcButtonGroup7: TfcButtonGroup;
    fcShapeBtn23: TfcShapeBtn;
    fcButtonGroup8: TfcButtonGroup;
    fcShapeBtn24: TfcShapeBtn;
    fcButtonGroup9: TfcButtonGroup;
    fcShapeBtn25: TfcShapeBtn;
    fcButtonGroup10: TfcButtonGroup;
    fcShapeBtn26: TfcShapeBtn;
    fcShapeBtn27: TfcShapeBtn;
    fcShapeBtn28: TfcShapeBtn;
    fcShapeBtn29: TfcShapeBtn;
    fcShapeBtn30: TfcShapeBtn;
    fcShapeBtn31: TfcShapeBtn;
    fcShapeBtn32: TfcShapeBtn;
    fcShapeBtn33: TfcShapeBtn;
    fcShapeBtn34: TfcShapeBtn;
    fcButtonGroup10fcShapeBtn1: TfcShapeBtn;
    fcButtonGroup10fcShapeBtn2: TfcShapeBtn;
    fcButtonGroup10fcShapeBtn3: TfcShapeBtn;
    fcButtonGroup10fcShapeBtn4: TfcShapeBtn;
    fcButtonGroup10fcShapeBtn5: TfcShapeBtn;
    fcButtonGroup10fcShapeBtn6: TfcShapeBtn;
    fcButtonGroup10fcShapeBtn7: TfcShapeBtn;
    Button1: TButton;
    fcButtonGroup11: TfcButtonGroup;
    fcShapeBtn35: TfcShapeBtn;
    procedure Timer1Timer(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
    procedure Basildi(Sender: TObject);
    procedure Memo1KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure Button1Click(Sender: TObject);
    procedure fcShapeBtn35Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Klavye2f: TKlavye2f;
  TopWindow: HWnd;
  k:pointer;
  h:hwnd;
  Formhandle:word;
  x:tagpoint;
  kopya:word;
  s:string;

implementation



{$R *.DFM}

procedure TKlavye2f.Timer1Timer(Sender: TObject);
begin
  if (GetForegroundWindow<>klavye2f.handle) and (GetForegroundWindow<>FormHandle) then
//   if  (GetForegroundWindow<>FormHandle) then
   FormHandle:=GetForegroundWindow;
end;




procedure Yaz(harf:string);
var handle:hwnd;
begin
  handle:=FormHandle;
  if Handle <> 0 then
  begin
    TopWindow := GetLastActivePopup(Handle);
    SetForegroundWindow(TopWindow);
  end;

{   sleep(10);

   k:=0;
   getcursorpos(x);
   h:=WindowFromPoint(x);
   AttachThreadInput(GetWindowThreadProcessId(form1.Handle,k),GetWindowThreadProcessId(getforegroundwindow,k),true) ;
   kopya:=getfocus;
}
//   SendMessage(kopya, WM_CHAR, Word(harf[1]), 0);

{
   Keybd_event(VK_TAB, 0, 0, 0);
   Keybd_event(VK_TAB, 0, KEYEVENTF_KEYUP, 0);
}
   Keybd_event(65, 0, 0, 0);
   Keybd_event(65, 0, KEYEVENTF_KEYUP, 0);


end;


procedure YazTus(Tuskod:byte);
var handle:hwnd;
begin
  handle:=FormHandle;
  if Handle <> 0 then
  begin
    TopWindow := GetLastActivePopup(Handle);
    SetForegroundWindow(TopWindow);
  end;

{   sleep(10);

   k:=0;
   getcursorpos(x);
   h:=WindowFromPoint(x);
   AttachThreadInput(GetWindowThreadProcessId(form1.Handle,k),GetWindowThreadProcessId(getforegroundwindow,k),true) ;
   kopya:=getfocus;
}
//   SendMessage(kopya, WM_CHAR, Word(harf[1]), 0);

{
   Keybd_event(VK_TAB, 0, 0, 0);
   Keybd_event(VK_TAB, 0, KEYEVENTF_KEYUP, 0);
}
   Keybd_event(TusKod, 0, 0, 0);
   Keybd_event(TusKod, 0, KEYEVENTF_KEYUP, 0);


end;


procedure TKlavye2f.BitBtn1Click(Sender: TObject);
begin
  s:=(sender as tbitbtn).caption;
//  YazTus((sender as tbitbtn).caption);
  YazTus(Ord(s[1]));


end;

procedure TKlavye2f.Basildi(Sender: TObject);
var tus:byte;
begin
   tus:=(sender as tfcShapeBtn).tag;
   YazTus(tus);
end;

procedure TKlavye2f.Memo1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  MEMO1.Lines.add(inttostr(key));
end;

procedure TKlavye2f.Button1Click(Sender: TObject);
var tus:byte;
    i:integer;
begin
  for i:=65 to 65 do
  begin
     tus:=i;
     YazTus(tus);
 end;
end;

procedure TKlavye2f.fcShapeBtn35Click(Sender: TObject);
var tus:byte;
    i:integer;
begin
  for i:=190 to 200 do
  begin
     tus:=i;
     YazTus(tus);
 end;

end;

procedure TKlavye2f.FormShow(Sender: TObject);
begin
  Top:=trunc(screen.height-klavye2f.height)-5;
  left:=trunc((screen.Width-klavye2f.Width)/2);
end;

procedure TKlavye2f.FormCreate(Sender: TObject);
var i:integer;
begin


end;

end.
